home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-09-08 | 1.6 KB | 52 lines | [TEXT/GEOL] |
- Item 9225073 8-Sept-89 00:40
-
- From: D1157 All Star Computer, L Goldman,PRT
-
- To: MACAPP.TECH$ MACAPP Tech
-
- Sub: Problem with Assertion
-
- Dear MacAppers:
-
- Re: Assertion:
-
- I like this routine. I sprinkle them at key places in my code to serve as
- "reality-checks".
-
- But it has a serious bug: Failure should be _always_ be called at the
- end of the routine. In that case, the program with debugging will function
- just like the non-debug version.
-
- As it stands in ß9, if I forget what I'm doing and just type 'G' in response to
- the Assertion failure, the program will proceed _in_spite_of_ the Assertion. If
- DebugStr is called, the program is _sure_ to die, because there is no way to
- signal failure from my debugger (TMON).
-
- Here's a better version:
-
- PROCEDURE Assertion(condition: Boolean; description: StringPtr);
- BEGIN
- IF NOT condition THEN
- BEGIN
- {$IFC qDebug}
- GetCallersMethodName(pWho);
- IF CanWriteLn THEN
- BEGIN
- WriteLn(Concat('Assertion failed in ', pWho, ': ', description^)
- EnterMacAppDebugger;
- END
- ELSE
- DebugStr(Concat('Assertion failed in ', pWho, ': ', description^
- {$EndC} {ƒƒƒ changed this line}
- Failure(minErr, 0); { ??? need to assign a message }
- {ƒƒƒ $EndC Remove this line}
- END;
- END;
-
- Further, I don't believe any non-zero message need be passed to Failure,
- because it is the responsibility of Failure handlers to update the message if
- they prefer.
-
- Larry Goldman
-
-